import 'package:flutter/material.dart';
import 'package:yurun_smartmerchants/view/loading_dialog.dart';

class LoadingUtil {
  static bool isLoading = false; //是否在loading中

  static void showLoading(context, {tip}) {
    if (isLoading) {
      return;
    }
    showDialog(
        context: context,
        barrierDismissible: false,
        builder: (context) {
          return LoadingDialog(
            tip: tip,
          );
        });
    isLoading = true;
  }

  static void hideLoading(context) {
    if (isLoading) {
      Navigator.pop(context);
      isLoading = false;
    }
  }
}
